import { createSSRApp } from "vue";
import { addFrontErr } from "@/api/base";



import App from "./App.vue";

// @ts-ignore 忽略类型检查，因为store模块没有类型声明文件
import store from './store'
// @ts-ignore 忽略类型检查，因为store模块没有类型声明文件
import check from './store/check'

// @ts-ignore 忽略类型检查
import objectPrototype from "./utils/object-prototype";
objectPrototype();


// @ts-ignore 忽略类型检查，因为store模块没有类型声明文件
const errorHandle = (err, vm, info) => {
    let errData = {
        msg: '支付宝小程序错误捕获',
        message: err.message,
        stack: err.stack,
        api: err.api,
        page: vm?.$scope?.$page,
        info: info,
    }

    addFrontErr({
        errMsg: JSON.stringify(errData),
        platform: "zulin_ali_err",
        remark: '全局错误捕获',
    });
}


export function createApp() {
    const app = createSSRApp(App);
    app.config.errorHandler = errorHandle;
    console.log(app, 'app');
    app.use(store)
    check(store)
    return {
        store,
        app,
    };
}
